/*
	This file is part of AVRCppLib.

    AVRCppLib is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    AVRCppLib is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with AVRCppLib.  If not, see <http://www.gnu.org/licenses/>.

    Copyright (C) Maxime Lemonnier 2007-2011
 */


#ifndef Logging_H_
#define Logging_H_

//#include "Utils.h"
#include "BitManipulation.h"

#ifdef MEMORY_LOGGING
	#define MEM_LOG_SIZE 100
#else
	#define MEM_LOG_SIZE 5
#endif

void OUT_OF_HEAP_MEMORY(size_t requested);
void OUT_OF_STACK_MEMORY(size_t requested);
void PRINT_MEMORY_STATUS();

void initLogging(void* mallocHeapStart);

size_t maxMemoryChunkLeft();

void * getHeapTop();

void updateHeapTop(size_t size, void* memory);

size_t heapSize();

void reallocLog(size_t size, void* memoryAsked, void* memoryObtained);

void mallocLog(size_t size, void* memory);

void freeLog(void* memory);

void printMemoryLog();

void verifyChecksum();

inline size_t stackSize() __attribute__((always_inline));

inline size_t distanceHeapFromStack() __attribute__((always_inline));

#include "Logging-definitions.h"

#endif /* Logging_H_ */
